class Solution:
    def successfulPairs(
        self, spells: List[int], potions: List[int], success: int
    ) -> List[int]:
        n, m = len(spells), len(potions)
        potions.sort()
        ans = [0] * n
        for i in range(n):
            l, r = -1, m
            while l + 1 < r:
                mid = l + (r - l)//2
                if potions[mid] < success / spells[i]  :
                    l = mid
                else:
                    r = mid
            ans[i] = m - r
        return ans
